package com.haoan.index.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.haoan.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haoan.common.annotation.Log;
import com.haoan.common.core.controller.BaseController;
import com.haoan.common.core.domain.AjaxResult;
import com.haoan.common.enums.BusinessType;
import com.haoan.index.domain.LcLeaveWord;
import com.haoan.index.service.LcLeaveWordService;
import com.haoan.common.utils.poi.ExcelUtil;
import com.haoan.common.core.page.TableDataInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 留言Controller
 * 
 * @author autoGen
 * @date 2025-03-20
 */
@Api(value="留言",tags = "留言")
@RestController
@Anonymous
@RequestMapping("/index/lcLeaveWord")
public class LcLeaveWordController extends BaseController
{
    @Resource
    private LcLeaveWordService lcLeaveWordService;

    /**
     * 查询留言列表
     */
    @ApiOperation("查询留言列表")
    @PreAuthorize("@ss.hasPermi('index:lcLeaveWord:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcLeaveWord lcLeaveWord)
    {
        startPage();
        List<LcLeaveWord> list = lcLeaveWordService.selectLcLeaveWordList(lcLeaveWord);
        return getDataTable(list);
    }

    /**
     * 导出留言列表
     */
    @ApiOperation("导出留言列表")
    @PreAuthorize("@ss.hasPermi('index:lcLeaveWord:export')")
    @Log(title = "留言", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LcLeaveWord lcLeaveWord)
    {
        List<LcLeaveWord> list = lcLeaveWordService.selectLcLeaveWordList(lcLeaveWord);
        ExcelUtil<LcLeaveWord> util = new ExcelUtil<LcLeaveWord>(LcLeaveWord.class);
        util.exportExcel(response, list, "留言数据");
    }

    /**
     * 获取留言详细信息
     */
    @ApiOperation("获取留言详细信息")
    @PreAuthorize("@ss.hasPermi('index:lcLeaveWord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lcLeaveWordService.selectLcLeaveWordById(id));
    }

    /**
     * 新增留言
     */
    @ApiOperation("新增留言")
    @PreAuthorize("@ss.hasPermi('index:lcLeaveWord:add')")
    @Log(title = "留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcLeaveWord lcLeaveWord)
    {
        return toAjax(lcLeaveWordService.insertLcLeaveWord(lcLeaveWord));
    }

    /**
     * 修改留言
     */
    @ApiOperation("修改留言")
    @PreAuthorize("@ss.hasPermi('index:lcLeaveWord:edit')")
    @Log(title = "留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcLeaveWord lcLeaveWord)
    {
        return toAjax(lcLeaveWordService.updateLcLeaveWord(lcLeaveWord));
    }

    /**
     * 删除留言
     */
    @ApiOperation("删除留言")
    @PreAuthorize("@ss.hasPermi('index:lcLeaveWord:remove')")
    @Log(title = "留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcLeaveWordService.deleteLcLeaveWordByIds(ids));
    }
}
